<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SSH Terminal</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm/css/xterm.css" />
    <style>
        #terminal {
            width: 100%;
            height: 400px;
        }
    </style>
</head>
<body>
<input type="text" id="wsUrl" placeholder="Enter WebSocket URL" />
<button onclick="connect()">Connect</button>
<div id="terminal"></div>
<script src="https://cdn.jsdelivr.net/npm/xterm/lib/xterm.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-attach/lib/xterm-addon-attach.js"></script>
<script>
    const terminal = new Terminal();
    terminal.open(document.getElementById('terminal'));
    function connect() {
        const wsUrl = document.getElementById('wsUrl').value;
        const socket = new WebSocket(wsUrl);
        socket.addEventListener('open', () => {
            const attachAddon = new AttachAddon.AttachAddon(socket);
            terminal.loadAddon(attachAddon);
        });
        socket.addEventListener('error', (error) => {
            console.error('WebSocket error:', error);
        });
    }
</script>
</body>
</html>